package com.jbp.controller;

import com.jbp.model.AppConfig;
import com.jbp.service.AgoraService;
import com.jbp.service.AppConfigService;
import com.jbp.utils.R;
import io.agora.media.RtcTokenBuilder;
import io.agora.rtm.RtmTokenBuilder;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.HashMap;
import java.util.Map;

/**
 * 声网
 * @author cc
 * @since 2020-07-04 23:42:42
 */
@Api(tags ="APP接口--声网" ,hidden = true)
@ApiIgnore
@RestController
@RequestMapping("rest/agora")
public class AgoraController {

    @Autowired
    private AgoraService agoraService;
    @GetMapping("/getRtctoken")
    public R getRtctoken(@RequestParam("channelName") String channelName, @RequestParam("uid") int uid){
        Map<String, String> map = new HashMap<>();
        map.put("token", agoraService.getRtctoken(channelName, uid, false));
        return R.ok(map);
    }

    @GetMapping("/getRtmtoken")
    public R getRtmtoken(@RequestParam("uid") String uid){
        Map<String, String> map = new HashMap<>();
        map.put("token", agoraService.getRtmtoken(uid));
        return R.ok(map);
    }

}